package com.snailct.bpp.router.datachange;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by huangxa on 2016/5/21.
 */
public class XmlMessageConfig {
    private static final Log logger = LogFactory.getLog(XmlMessageConfig.class);
    private String xmlFileName;
    private String xmlFileDec;
    private String messageDirect;
    private String xsdFileStatus;
    private String status;
    private int id;

    /**
     * 生成xml配置文件
     */
    public void xmlFileToTable(){
        String sql = "insert into SOA_SYS_XMLMessageConfig(XMLFileName,XMLFileDesc,messageDirection,status,xsdFileStatus)";
        sql += " values('"+xmlFileName+"','"+xmlFileDec+"','"+messageDirect+"','"+status+"','"+xsdFileStatus+"')";
        logger.info("执行SQL语句为:"+sql);
        DaoOperation.execute(sql);
    }
    public void updateFileToTable(){
        String sql = "update SOA_SYS_XMLMESSAGECONFIG set status=1 where XMLFILENAME='"+xmlFileName+"'";
        logger.info("执行SQL语句为:"+sql);
        DaoOperation.execute(sql);
    }

    public String getXmlFileName(String serviceId){
        String sql = "select xmlfilename from SOA_SYS_XMLMESSAGECONFIG where serviceid='"+serviceId+"'";
        ResultSet rs = DaoOperation.executeQuery(sql);
        try {
            if(rs.next()){
                return rs.getString("xmlfilename");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static Log getLogger() {
        return logger;
    }

    public String getXmlFileName() {
        return xmlFileName;
    }

    public void setXmlFileName(String xmlFileName) {
        this.xmlFileName = xmlFileName;
    }

    public String getXmlFileDec() {
        return xmlFileDec;
    }

    public void setXmlFileDec(String xmlFileDec) {
        this.xmlFileDec = xmlFileDec;
    }

    public String getMessageDirect() {
        return messageDirect;
    }

    public void setMessageDirect(String messageDirect) {
        this.messageDirect = messageDirect;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getXsdFileStatus() {
        return xsdFileStatus;
    }

    public void setXsdFileStatus(String xsdFileStatus) {
        this.xsdFileStatus = xsdFileStatus;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
